package com.zhipu.balance.remotedata;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.zhipu.balance.remotedata.systemapi.SystemApiService;
import com.zhipu.balance.ui.vm.activate.ActivateViewModel;
import com.zhipu.balance.ui.vm.home.GeneralBalanceModel;
import com.zhipu.balance.ui.vm.home.HomeViewModel;
import com.zhipu.balance.ui.vm.home.calculate.corn.CornFaultinessViewModel;
import com.zhipu.balance.ui.vm.home.calculate.corn.CornImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.corn.CornRongZhongViewModel;
import com.zhipu.balance.ui.vm.home.calculate.corn.CornViewModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiBrokenViewModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiFaultinessViewModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiIntermixingModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiViewModel;
import com.zhipu.balance.ui.vm.home.calculate.dami.DaMiYellowGrainViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedDamageViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedImmatureGrainViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedMildewViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedSporeViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rapeseed.RapeseedViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceBrownViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceFinishingViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceIntermixingViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceRougheningViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceYellowGrainViewModel;
import com.zhipu.balance.ui.vm.home.calculate.rice.RiceYieldViewModel;
import com.zhipu.balance.ui.vm.home.calculate.soybean.SoybeanCompleteViewModel;
import com.zhipu.balance.ui.vm.home.calculate.soybean.SoybeanDamageViewModel;
import com.zhipu.balance.ui.vm.home.calculate.soybean.SoybeanHotDamageViewModel;
import com.zhipu.balance.ui.vm.home.calculate.soybean.SoybeanImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.soybean.SoybeanViewModel;
import com.zhipu.balance.ui.vm.home.calculate.wheat.WheatGlutenViewModel;
import com.zhipu.balance.ui.vm.home.calculate.wheat.WheatImpurityViewModel;
import com.zhipu.balance.ui.vm.home.calculate.wheat.WheatRongZhongViewModel;
import com.zhipu.balance.ui.vm.home.calculate.wheat.WheatViewModel;
import com.zhipu.balance.ui.vm.home.calculate.wheat.WheeatFaultinessViewModel;
import com.zhipu.balance.ui.vm.home.record.RecordViewModel;
import com.zhipu.balance.ui.vm.home.revise.ReviseModel;
import com.zhipu.balance.ui.vm.home.system.SystemSettingViewModel;
import com.zhipu.balance.ui.vm.home.system.device.DeviceViewModel;
import com.zhipu.balance.ui.vm.home.system.number.NumberManagementViewModel;
import com.zhipu.balance.ui.vm.home.system.personnel.PersonnelViewModel;

import javax.inject.Inject;


public class ViewModelFactory implements ViewModelProvider.Factory {

    private SystemApiService mSystemApiService;

    @Inject
    public ViewModelFactory(SystemApiService mSystemApiService) {
        this.mSystemApiService = mSystemApiService;
    }


    @NonNull
    @Override
    public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
        if (modelClass.isAssignableFrom(HomeViewModel.class)) {
            return (T) new HomeViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(ActivateViewModel.class)){
            return (T) new ActivateViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(GeneralBalanceModel.class)){
            return (T) new GeneralBalanceModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(ReviseModel.class)){
            return (T) new ReviseModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SystemSettingViewModel.class)){
            return (T) new SystemSettingViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceViewModel.class)){
            return (T) new RiceViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DeviceViewModel.class)){
            return (T) new DeviceViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(PersonnelViewModel.class)){
            return (T) new PersonnelViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceImpurityViewModel.class)){
            return (T) new RiceImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceRougheningViewModel.class)){
            return (T) new RiceRougheningViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceFinishingViewModel.class)){
            return (T) new RiceFinishingViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceBrownViewModel.class)){
            return (T) new RiceBrownViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceYellowGrainViewModel.class)){
            return (T) new RiceYellowGrainViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceIntermixingViewModel.class)){
            return (T) new RiceIntermixingViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RiceYieldViewModel.class)){
            return (T) new RiceYieldViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(WheatViewModel.class)){
            return (T) new WheatViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(WheatImpurityViewModel.class)){
            return (T) new WheatImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(WheeatFaultinessViewModel.class)){
            return (T) new WheeatFaultinessViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(WheatGlutenViewModel.class)){
            return (T) new WheatGlutenViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(CornViewModel.class)){//玉米
            return (T) new CornViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(CornImpurityViewModel.class)){//玉米
            return (T) new CornImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(CornFaultinessViewModel.class)){//玉米
            return (T) new CornFaultinessViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiViewModel.class)){//大米
            return (T) new DaMiViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiBrokenViewModel.class)){//大米
            return (T) new DaMiBrokenViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiFaultinessViewModel.class)){//大米
            return (T) new DaMiFaultinessViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiImpurityViewModel.class)){//大米
            return (T) new DaMiImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiIntermixingModel.class)){//大米
            return (T) new DaMiIntermixingModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(DaMiYellowGrainViewModel.class)){//大米
            return (T) new DaMiYellowGrainViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SoybeanViewModel.class)){//大豆
            return (T) new SoybeanViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SoybeanCompleteViewModel.class)){//大豆
            return (T) new SoybeanCompleteViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SoybeanDamageViewModel.class)){//大豆
            return (T) new SoybeanDamageViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SoybeanHotDamageViewModel.class)){//大豆
            return (T) new SoybeanHotDamageViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(SoybeanImpurityViewModel.class)){//大豆
            return (T) new SoybeanImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedViewModel.class)){//功能计算-油菜籽VM
            return (T) new RapeseedViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedImpurityViewModel.class)){//功能计算-油菜籽VM
            return (T) new RapeseedImpurityViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedSporeViewModel.class)){//油菜籽生芽粒
            return (T) new RapeseedSporeViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedMildewViewModel.class)){//油菜籽生霉粒
            return (T) new RapeseedMildewViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedDamageViewModel.class)){//油菜籽热损伤粒
            return (T) new RapeseedDamageViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RapeseedImmatureGrainViewModel.class)){//油菜籽热损伤粒
            return (T) new RapeseedImmatureGrainViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(NumberManagementViewModel.class)){//编号管理VM
            return (T) new NumberManagementViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(RecordViewModel.class)){//使用记录VM
            return (T) new RecordViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(WheatRongZhongViewModel.class)){
            return (T) new WheatRongZhongViewModel(mSystemApiService);
        }else if(modelClass.isAssignableFrom(CornRongZhongViewModel.class)){
            return (T) new CornRongZhongViewModel(mSystemApiService);
        }
        throw new IllegalArgumentException("未知类名");
    }
}